package com.myutils.commons.utils.date;


import com.myutils.commons.BaseParams;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtilsParams extends BaseParams {

    public static Object[] dateToStringParams() {
        String dateStr = "2013-2-01 11:9:12";
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = null;
        try {
            date = format.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return $(
                $(date, DateFormatEnum.YYYY_MM_DD_HH_MM_SS, "2013-02-01 11:09:12"),
                $(date, DateFormatEnum.YYYYMMDDHHMMSS, "20130201110912"),
                $(date, DateFormatEnum.YYYY_MM_DD, "2013-02-01"),
                $(date, DateFormatEnum.YYYYMMDD, "20130201"),
                $(date, DateFormatEnum.MM_DD, "02-01"),
                $(date, DateFormatEnum.HH_MM_SS, "11:09:12"),
                $(date, DateFormatEnum.HHMMSS, "110912")

        );
    }

    public static Object[] dateToStrParams() {
        String dateStr = "2013-2-01 11:9:12";
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = null;
        try {
            date = format.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return $(
                $(date, "yyyy-MM-dd HH:mm:ss", "2013-02-01 11:09:12"),
                $(date, "yyyyMMdd HHmmss", "20130201 110912"),
                $(date, "yyyy-MM-dd", "2013-02-01"),
                $(date, "yyyyMMdd", "20130201"),
                $(date, "MM-dd", "02-01"),
                $(date, "HH:mm:ss", "11:09:12"),
                $(date, "HHmmss", "110912"),
                $(date, "yyyy/MM/dd HH:mm:ss", "2013/02/01 11:09:12"),
                $(date, "yyyy/MM/dd", "2013/02/01")

        );
    }

    /**
     * 日期对象转字符串参数构造:异常输入测试
     *
     * @return
     */
    public static Object[] dateToStrIsNullParams() {
        return $($(null, DateFormatEnum.HH_MM_SS), $(new Date(), null),
                $(null, null));
    }

    /**
     * 字符串转换为日期对象参数构造
     *
     * @return
     */
    public static Object[] strToDateParams() {
        return $(
                $("2011-2-4 2:56:0", DateFormatEnum.YYYY_MM_DD_HH_MM_SS,
                        "Fri Feb 04 02:56:00 CST 2011"),
                $("16:56:0", DateFormatEnum.HH_MM_SS, "Thu Jan 01 16:56:00 CST 1970"),
                $("021307", DateFormatEnum.HHMMSS, "Thu Jan 01 02:13:07 CST 1970"),
                $("23454", DateFormatEnum.HHMMSS, "Thu Jan 01 23:45:04 CST 1970"),
                $("20110416", DateFormatEnum.YYYYMMDD, "Sat Apr 16 00:00:00 CST 2011"),
                $("2000-2-9", DateFormatEnum.YYYY_MM_DD, "Wed Feb 09 00:00:00 CST 2000"),
                $("2012102305129", DateFormatEnum.YYYYMMDDHHMMSS, "Tue Oct 23 05:12:09 CST 2012"),
                $("12-9", DateFormatEnum.MM_DD, "Wed Dec 09 00:00:00 CST 1970")

        );
    }

    /**
     * 字符串转换为日期对象参数构造:异常输入测试
     *
     * @return
     */
    public static Object[] strToDateIsNullParams() {
        return $(
                $(null, DateFormatEnum.HH_MM_SS),
                $("2033-12-3", null),
                $(null, null)
        );
    }

    /**
     * 字符串转换为日期对象参数构造:格式转换失败
     *
     * @return
     */
    public static Object[] strToDateParseParams() {
        return $(
                $("3:23:8", DateFormatEnum.MM_DD),
                $("2013-2-4", DateFormatEnum.YYYY_MM_DD_HH_MM_SS)
        );
    }
}
